//
//  MaintenanceDetailedViewController.h
//  FMS
//
//  Created by Steven on 10/16/13.
//  Copyright (c) 2013 QGSVN. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "FilterViewController.h"
#import "DatePickerViewController.h"
#import "DetailedItemViewController.h"

enum {
    REJECT = 0,
    APPROVE
};

@protocol DatePickerViewDelegate;

@interface MaintenanceDetailedViewController : UIViewController <UITableViewDataSource,UITableViewDelegate,DatePickerViewDelegate,FilterViewDelegate,UIAlertViewDelegate,UIImagePickerControllerDelegate,UIPopoverControllerDelegate,UINavigationControllerDelegate> {
    NSDictionary *dictLanguage;
    NSMutableArray *mainArray;
    NSMutableArray *itemInfoArray;
    NSMutableArray *workStatusArray;
    
    UIPopoverController *popoverController;
    int serviceType;
    int maintenanceTypeId;
    int currentSelectedIndex;
    int currentFSR;
    int currentAttachDocumentType;
    
    DCRoundSwitch *workCompleteSwitch;
    DCRoundSwitch *inspectionResultSwitch;
    DCRoundSwitch *followActionSwitch;
    
    UIPopoverController *popController;
    UIImagePickerController* imagePickerController;
    
    NSString *newInspectionId;
    NSString *newScheduleId;
    NSMutableDictionary *beforeInspectionSavedDict;
    NSMutableDictionary *beforeScheduleSavedDict;
}

@property (unsafe_unretained) id<DatePickerViewDelegate> delegate;
@property (unsafe_unretained) id parent;
@property (assign,readwrite) BOOL isEdit;
@property (assign,readwrite) int itemType; //Building or Facility
@property (strong, nonatomic) NSMutableDictionary *itemDetailDict;
@property (strong, nonatomic) IBOutlet UITableView *mainTableView;
@property (strong, nonatomic) IBOutlet UILabel *lbMainTitle;
@property (strong, nonatomic) IBOutlet UIButton *btnBack;
@property (strong, nonatomic) IBOutlet UIButton *btnRightCorner;
@property (strong, nonatomic) IBOutlet UIButton *btnInspection;
@property (strong, nonatomic) IBOutlet UIButton *btnMaintenance;

@property (strong, nonatomic) IBOutlet UIView *titleContainerView;
@property (strong, nonatomic) IBOutlet UIView *mainTitleContainerView;

@property (strong, nonatomic) NSMutableDictionary *personInChargeDict;
@property (strong, nonatomic) NSMutableDictionary *typeRequirementDict;

@property (strong, nonatomic) NSMutableDictionary *inputMaintenanceDict;
@property (strong, nonatomic) NSMutableDictionary *inputInspectionDict;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil parent:(id)_parent serviceType:(int)_serviceType;
- (IBAction)backPreviousView:(id)sender;
- (IBAction)handleRightCornerEvent:(id)sender;
- (IBAction)switchSegment:(UIButton *)sender;

//confirm to choose Maintenance Type from previous view
- (void) initNewControllerBeforeConfirmMaintenance:(NSMutableDictionary*)_dict itemDetailedDict:(NSMutableDictionary*)_itemDetailedDict;
- (void) confirmMaintenanceType:(NSMutableDictionary*)_maintenanceTypeDict itemDetailedDict:(NSMutableDictionary*)_itemDetailedDict;
- (void) handleCostingRequest:(int)_isApproved;
- (void) checkStatusOfDetail;
- (void) reloadMaintenanceAttachment;
- (void) dismissPopoverController;
- (void) saveMaintenanceWithSendEmail:(BOOL)sendMail;

@end
